Skip to content

Conversation

@32th-System
Copy link

@32th-System 32th-System commented Dec 6, 2025

Becuase stdlib.h was not included, malloc was not declared anywhere. In C, using an undeclared function makes the compiler pretend that it's declared and has a signature of

int func();

meaning that the return value is a 32 bit int and the parameters can be whatever.

As a result of this, after the malloc call, the compiler would insert an instruction to sign extend the lower 32 bits of the RAX register into the upper 32 bits, which would of course create a pointer that is invalid in a lot of cases.

Fixes #137 though I only found this bug report after I already wrote all this other shit

Becuase stdlib.h was included, malloc was not declared anywhere. In C,
using an undeclared function makes the compiler pretend that it's
declared and has a signature of

int func();

meaning that the return value is a 32 bit int and the parameters can be
whatever.

As a result of this, after the malloc call, the compiler would insert an
instruction to sign extend the lower 32 bits of the RAX register into
the upper 32 bits, which would of course create a pointer that is
invalid in a lot of cases
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[msvc] Application crashes when rendering a video

1 participant